package com.sdp.th.netty.bizc;

import org.springframework.stereotype.Service;

import com.sdp.core.bizc.utils.ApplicationContextUtils;
import com.sdp.th.cache.caches.EqStateCache;
import com.sdp.th.db.th_eq_state.service.IThEqStateService;
import com.sdp.th.utils.ThConstants;

import lombok.extern.slf4j.Slf4j;

@Service
@Slf4j
public class OfflineBusinessImpl implements BusinessService{

	@Override
	public void execute(Object obj) {
		String deviceNo = (String) obj;
		// 更新设备在线状态
		ApplicationContextUtils.getBean(IThEqStateService.class).updateLineState(deviceNo, ThConstants.否.getCode());
		log.info("**************检测到设备离线《更新设备状态为离线》业务完成");
		
		// 更新缓存中设备在线状态
		ApplicationContextUtils.getBean(EqStateCache.class).updateLineStateCache(deviceNo, ThConstants.否.getCode());
		log.info("**************检测到设备离线《更新设备缓存为离线》缓存业务完成");
	}

	@Override
	public BusinessEnum getBusinessType() {
		return BusinessEnum.设备离线;
	}

}
